<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>

    <!-- start: Meta -->
    <base href="">
    <meta charset="utf-8">
    <title>GM</title>
    <meta name="description" content="">
    <meta name="author" content="">
    <meta name="keyword" content="">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Cache-control" content="no-cache">
    <meta http-equiv="Cache" content="no-cache">
    <!-- end: Meta -->

    <!-- start: Mobile Specific -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- end: Mobile Specific -->

    <!-- start: CSS -->
    <link id="bootstrap-style" href="../css/bootstrap.min.css" rel="stylesheet">
    <link href="../css/bootstrap-responsive.min.css" rel="stylesheet">
    <link id="base-style" href="../css/style.css" rel="stylesheet">
    <link id="base-style-responsive" href="../css/style-responsive.css" rel="stylesheet">

    <!-- The HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <link id="ie-style" href="../css/ie.css" rel="stylesheet">
    <![endif]-->

    <!--[if IE 9]>
    <link id="ie9style" href="../css/ie9.css" rel="stylesheet">
    <![endif]-->

    <!-- start: Favicon -->
    <link rel="shortcut icon" href="../img/favicon.ico">
    <!-- end: Favicon -->

</head>

<body> <div class="row-fluid sortable">
    <div class="box span12">
        <div class="box-header" data-original-title>
            <h2>
                <i class="halflings-icon white edit"></i>
                <span class="break"></span>添加排程
            </h2>
            <div class="box-icon">
                <a href="#" class="btn-setting">
                    <i class="halflings-icon white wrench"></i>
                </a>
                <a href="#" class="btn-minimize">
                    <i class="halflings-icon white chevron-up"></i>
                </a>
                <a href="#" class="btn-close">
                    <i class="halflings-icon white remove"></i>
                </a>
            </div>
        </div>
        <div class="box-content">
            <form class="form-horizontal" id="addForm" action="../cardOper/addCardOper.do" method="POST">
                <input type="hidden" value="${blid}" name="blid" id="blid"/>
                <input type="hidden" value="" name="operTime" id="operTime"/>
                <fieldset>
                    <label class="control-label" for="_blid">账单号</label>
                    <div class="form-group controls" style="width: 446px;" title="账单号">
                        <input type="text" class="form-control" name="_blid" id="_blid" value="${blid}" disabled="disabled">
                    </div>

                    <label class="control-label" for="type">操作类型</label>
                    <div class="form-group controls" style="width: 446px;" title="操作类型">
                        <select id="type" data-rel="chosen" name="type">
                            <option value="-1" selected>消费</option>
                            <option value="1">还款</option>
                        </select>
                    </div>

                    <label class="control-label" for="operMoney">金额</label>
                    <div class="form-group controls" style="width: 446px;" title="还款日">
                        <input type="text" class="form-control" name="operMoney" id="operMoney" placeholder="请输入消费/提现 金额">
                    </div>

                    <label class="control-label" for="operator">刷卡机编号</label>
                    <div class="form-group controls" style="width: 446px;" title="还款日">
                        <input type="text" class="form-control" name="operator" id="operator" placeholder="请输入刷卡机编号">
                    </div>


                    <label class="control-label" for="_operTime">操作日期</label>
                    <div class="form-group controls" style="width: 446px;" title="还款日">
                        <input type="text" id="_operTime" name="_operTime" class="input-xlarge datepicker" readonly="readonly">
                    </div>

                    <div class="form-actions">
                        <button type="submit" class="btn btn-primary">保存</button>
                        <button type="reset" class="btn" onClick="javascript:location.href='../cardOper/gotoCardOperList.web?blid=${blid}'">返回</button>

                    </div>
                </fieldset>
            </form>

        </div>
    </div><!--/span-->

</div><!--/row-->

<!-- start: JavaScript-->

<script src="../js/jquery-1.9.1.min.js"></script>
<script src="../js/jquery-migrate-1.0.0.min.js"></script>

<script src="../js/jquery-ui-1.10.0.custom.min.js"></script>

<script src="../js/jquery.ui.touch-punch.js"></script>

<script src="../js/modernizr.js"></script>

<script src="../js/bootstrap.min.js"></script>

<script src="../js/jquery.uniform.min.js"></script>
<script src="../js/bootstrap-validator/bootstrapValidator.min.js"></script>
<script src="../js/jquery.noty.js"></script>
<script src="../js/common.js"></script>
<script>
    $(function(){
        $('.datepicker').datepicker({
            changeMonth: true,
            changeYear: true,
            onSelect: function(dateText, inst) {
                $("#operTime").val( $('.datepicker').datepicker("getDate").getTime());
            }
        });
        $('#addForm')
                .bootstrapValidator({
                    feedbackIcons: {
                        valid: 'glyphicon glyphicon-ok',
                        invalid: 'glyphicon glyphicon-remove',
                        validating: 'glyphicon glyphicon-refresh'
                    },
                    fields: {

                        operMoney: {
                            validators: {
                                notEmpty: {
                                    message: '金额不能为空'
                                },
                                regexp: {
                                    regexp: /^(-?\d+)(\.\d+)?$/,
                                    message: "金额必须是正数字"
                                },
                                greaterThan: {
                                    value: 1,
                                    message: '金额必须小于1'
                                },
                                lessThan: {
                                    value: 30000,
                                    message: '金额必须小于30000'
                                }

                            }
                        },
                        operator: {
                            validators: {
                                regexp: {
                                    regexp: /^(-?\d+)(\.\d+)?$/,
                                    message: "金额必须是正数字"
                                },
                                greaterThan: {
                                    value: 0,
                                    message: '金额必须大于0'
                                }
                            }

                        },
                        _operTime: {
                            validators: {
                                notEmpty: {
                                    message: '操作日期不能为空'
                                }
                            }
                        }

                    }
                })
                .on('success.form.bv', function(e) {
                    // Prevent form submission
                    e.preventDefault();

                    var $form = $(e.target);

                    //Use Ajax to submit form data

                    console.log($form.serialize());
                    ajaxParam($form.attr('action'), $form.serialize(), 10000, 'POST', 'json', doSuccess);

                    function doSuccess(res) {
                        console.log(res);
                        if(res.status == 100){
                            noty({"text":"新增成功","layout":"top","type":"success"});
                            setTimeout(function () {
                                window.location.href="../cardOper/gotoCardOperList.web?blid=" + $("#blid").val();
                            }, 3000);
                        }else{
                            noty({"text":res.error,"layout":"top","type":"alert","closeButton":"true"});
                        }
                    }

                });
    });
</script>
</body>
</html>
